<?php
  class Plugins_Vdocover extends model {
  
  
  
  function getformadd($productid="")
  {
  

  

  
  
//  $str='<div>VDO<div class="vdoclass" style="width:640px;height:360px"></div><div><input type="button" name="link[]" value="link"></div></div>';
 
  $str='<div class="wrpPlg clBg5 clBd2 bdFull">
                    <div class="plgArea vdoclass"></div>
                    <div class="wrpOutAtcPlg">
                        <div class="wrpAtcPlg">
                            <span class="ico icoOri icoVdoPlg"></span>
                            <div class="spnAtcPlg clTxtW">
                                <span class="txtAtcPlg fs03">Youtube</span>
                                <br>
                                <span class="rcmSizeAdd fs01">+ Video Cover</span>
                            </div>
                        </div>
                    </div>
                    <div class="wrpTl">
                        <div title="Close" class="btnIco closeTl clBd3 mgBtm10 deleterowbutton">
                            <span class="ico icoCloseTl"></span>
                        </div>
                        <div class="addTool">
                            <div title="Link" class="btnIco addLnkVdoTl clBd3 bdBtm linkvdobutton">
                                <span class="ico icoAddLnkTl"></span>
                            </div>
                            
                            <div title="Cover" class="btnIco addImgTl clBd3 bdBtm cvrPop imgvdobutton">
                                <span class="ico icoAddImgTl"></span>
                            </div>
                            
                            <div title="Remove" class="btnIco btnRmvTl deletevdobutton">
                                <span class="ico icoRmvTl"></span>
                            </div>
                        </div>
                    </div>
                    <span class="desPlg clTxt3 fs03">Explain more about your stuff by add some vdo clip for it.</span>
                    
                    
                    
                </div>
                
                <form onsubmit="return false;" class="frmTprPlgAdd2"><input type="text" placeholder="desc" class="inpAddCtntNoBd inpTprPlg w616 clTxt2 fs03" name="detail[]">                        </form>
                ';
 
 
  $arraydata['form']=addslashes(str_replace(array("\r", "", "\r"), '', $str));
 // $arraydata['js'][]=pluginjsinfo.'/vdo.js';


  
  
      
  
  
  
  return $arraydata;
  
  
  
  
  
  
  
  }
  
  function getformlanding($arraydata)
  {
  $code = '<div class="ldIt wrpVdoLd clBg4 w640">';
  
 if(strpos($arraydata['url'],'mp4')!==false )
{
$code .=' <video width="100%" height="360" controls><source src="'.$arraydata['url'].'" type="video/mp4"></video>';
}else
{
if(strpos($arraydata['url'],'youtu.be')!==false)
{
$arrayurl=explode('/',$arraydata['url']);
$arraydata['url']='https://www.youtube.com/embed/'.$arrayurl[count($arrayurl)-1].'?wmode=transparent';

}


$code .=' <iframe width="100%" height="360" src="'.$arraydata['url'].'"> </iframe>';
} 
  $code .= '</div>';

$data['str']=$code;
$data['target']='secondtarget';

return $data;
  
  
  }
  
  function getplugin($plugreid)
  {
  
  $sql="select * from tb_plugins_vdocover where plugreid=".$plugreid;
  $arrayplugin=$this->db->db_set_1recordrow($sql);
  
  if(strpos($arrayplugin['url'],'youtu.be')!==false)
{
$arrayurl=explode('/',$arrayplugin['url']);
$arrayplugin['url']='https://www.youtube.com/embed/'.$arrayurl[count($arrayurl)-1].'?wmode=transparent';
$arrayplugin['embed']=$arrayurl[count($arrayurl)-1];

}

$arrayplugin['img']= $this->getimagebyimgmid($arrayplugin['imgmid']);
     $arrayplugin['simg']= $this->getimagebyimgmid($arrayplugin['simgmid']);
  

  return $arrayplugin;
  
  

  
  }
  
  function saveplugin($arraydata,$productid,$plugreid)
  {
  
  $arraydata['productid']=$productid;
  $arraydata['plugreid']=$plugreid;
  
  
  
    if($arraydata['photomain'])
  {
  $arraydata['imgmid']= $this->savephotobase64($arraydata['photomain']);
  $arraydata['simgmid']=$arraydata['imgmid'];
  unset($arraydata['photomain']);
  
  }
  else if($arraydata['photolink'])
            {
            $arraydata['imgmid']=$this->savephotolink($arraydata['photolink']);
            $arraydata['simgmid']=$this->savephotolink($arraydata['photolink'],640);
            unset($arraydata['photolink']);   
            
            }
 else if($arraydata['photopath'])
            {
            $arraydata['imgmid']=$this->savephotopath($arraydata['photopath']);
            $arraydata['simgmid']=$this->savephotopath($arraydata['photopath'],640);
            unset($arraydata['photopath']);  
            
            }
            
            
 if($arraydata['simgmid'])$arraydata['simgmid']=$this->swicthpathimage($arraydata['simgmid'],$productid);
 
   if($arraydata['imgmid'])
  {
  $arraydata['imgmid']=$this->swicthpathimage($arraydata['imgmid'],$productid);
  
  }
  
  
  
  
  $this->db->db_set($arraydata,'tb_plugins_vdocover');
  
  }
  
  
  }
?>
